﻿#region

using System.Data.Entity.ModelConfiguration;
using HouseHoldBudget.Core.Entities.Budgets;

#endregion

namespace HouseHoldBudget.Data.Mapping.Budgets
{
    public class BudgetMap : EntityTypeConfiguration<Budget>
    {
        #region Constructors

        public BudgetMap()
        {
            ToTable("Budget");
            HasKey(c => c.Id);

            Property(u => u.BudgetCreatedOn);
            Property(u => u.BudgetDescription);
            Property(u => u.BudgetName);
            Property(u => u.BudgetUpdatedOn);
            Property(u => u.BudgetTypeId);

            //Budget Owner ForeignKey
            HasOptional(c => c.BudgetOwner)
                .WithMany()
                .HasForeignKey(c => c.BudgetOwnerId).WillCascadeOnDelete(false);

            //Budget Actors list
            HasMany(c => c.BudgetActors)
                .WithMany()
                .Map(m => m.ToTable("BudgetActors"));

        }

        #endregion
    }
}